//
//  imageCell.m
//  MyFamily
//
//  Created by 陆洋 on 15/6/4.
//  Copyright (c) 2015年 maili. All rights reserved.
//

#import "imageCell.h"
#import "UIImage+ReSize.h"
#import "UIImageView+WebCache.h"

@interface imageCell()

@property (weak, nonatomic) IBOutlet UIImageView *headImage;
@property (weak, nonatomic) IBOutlet UIImageView *bgImageView;
@property (weak, nonatomic) IBOutlet UIImageView *sendImageView;

@end

@implementation imageCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.backgroundColor = WRGBColor(235, 240, 244);
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)setCellValue:(NSString *)sendImage;
{
    UIImage *image = [UIImage imageNamed:@"chatfrom_bg_normal.png"];
    image = [image resizableImageWithCapInsets:(UIEdgeInsetsMake(image.size.height * 0.6, image.size.width * 0.4, image.size.height * 0.3, image.size.width * 0.4))];
    
    self.headImage.image = [UIImage imageNamed:@"phone_kf.png"];

    if ([sendImage containsString:@"http://"]) {
        [self.sendImageView sd_setImageWithURL:[NSURL URLWithString:sendImage] placeholderImage:[UIImage imageNamed:@"phone_defulimg.png"]];
    } else {
        self.sendImageView.image = [[UIImage alloc] initWithContentsOfFile:sendImage];
    }
//    self.sendImageView.image = [sendImage reSizeImagetoSize:CGSizeMake(sendImage.size.width, sendImage.size.height)];
//    CALayer *layer = [self.sendImageView layer];
//    [layer setMasksToBounds:YES];
//    [layer setCornerRadius:6.0];
}

+(instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *identifier = @"imageCell";
    
    //缓存中取
    imageCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    
    //创建
    if (!cell)
    {
        cell = [[imageCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    //cell.userInteractionEnabled = NO;  //不让用户点击
    return cell;
}

@end
